<?php

 // Debug mode 
//define('DEBUG',true); 
//ini_set('display_errors', 1);
//ini_set('log_errors', 1);
//ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
///error_reporting(E_ALL);




//echo ABSPATH;
//exit;
//echo site_path;

/*
 * Auto load class from the class folder
 */
function __autoload($class_name) {
    //Load classes form the classes folder
    $filename = $class_name . '.php';
    $file = ABSPATH . 'classes' . DIRSEP . $filename;
  //    echo  "<br>". $file;
    if (file_exists($file)) {
        include ($file);
        return true;
        //    echo "looking in classes: ". $file;
    }

 
    //Load classes form the library folder
    $filename = $class_name . '.php';
    $file = ABSPATH . 'library' . DIRSEP .$filename;
   // echo  "<br>". $file;
    if (file_exists($file)) {
     //   echo "looking in library: ". $file;
        include ($file);
        return true;
        
    }
    exit;   
    return false;
}



// Open Database Connection
$result = Database::connect(
Configuration::$APP_DB_SERVER,
Configuration::$APP_DB_SERVER_USERNAME,
Configuration::$APP_DB_SERVER_PASSWORD,
Configuration::$APP_DB_DATABASE
);
if (!$result) {
    echo("Could not connect to database server");
    exit;
} 
//print_r($result);

//cura not required authentication will be handled using wordpress

//$cura = new Cura(Configuration::$APP_DB_DATABASE, Configuration::$APP_DB_SERVER_USERNAME, Configuration::$APP_DB_SERVER_PASSWORD, Configuration::$APP_DB_SERVER);
//Application::start();

//echo "app_start";
?>
